document.write("<script src='js/jquery/jquery.js'></script>");




var $dialog;

function enterFamilyInfo() {

		$dialog.dialog('close');
	
	    $dialog = $("#addFamilyMemberForm")
		.dialog({
			draggable: false,
			modal: true,
			resizable: false,
			show: 'slide',
			autoOpen: false,
			height: 500,
			width: 700,
			title: 'Add Family Member Form'
		});

	
	$dialog.dialog('open');
	return false;
}

function sendEmail() {
	
    $dialog = $("#forgetPasswordForm")
	.dialog({
		draggable: false,
		modal: true,
		resizable: false,
		show: 'slide',
		autoOpen: false,
		height: 500,
		width: 700,
		title: 'Forget Password?'
	});


	$dialog.dialog('open');
	return false;
}



function addFamilyMember() {
	
		    $dialog = $("<div class='add-persons'>"+
							"<a href='#' onclick='enterFamilyInfo()' class='add-sibling'>Add Siblings</a>"+
							"<a href='#' onclick='enterFamilyInfo()' class='add-partner'>Add Partner</a>"+
							"<a href='#' onclick='enterFamilyInfo()' class='add-children'>Add Children</a>"+
							"<a href='#' onclick='enterFamilyInfo()' class='add-parents'>Add Parents</a>"+
							"<a href='#' onclick='enterFamilyInfo()' class='edit-profile'>Edit Profile</a>"+
						"</div>")
			.dialog({
				draggable: false,
				modal: true,
				resizable: false,
				show: 'slide',
				autoOpen: false,
				width:280,
				height:250,
				title: 'Add Family Member'
			});

		
			$dialog.dialog('open');
			// prevent the default action, e.g., following a link
			return false;
}

function validateBirthDate() {
    //more information at http://jqueryui.com/demos/datepicker
    $("#datepicker1").datepicker({
		dateFormat: "dd/mm/yy",
		//set the animation to be drop
		showAnim: "drop",

		//enable the month and year drop down box
		changeMonth: true,
		changeYear: true,
		yearRange: "1800:2011",
		
		//datepicker start at current date
		gotoCurrent: true,

		//min date can only be 100 year back, eg cannot enter 1800 as the year of birth
		minDate: "-200Y",

		//max date can only be today
		maxDate: +0
		
    }); 
}

function validateDeceasedDate() {
	 //more information at http://jqueryui.com/demos/datepicker
    $("#datepicker2").datepicker({
		dateFormat: "dd/mm/yy",
		//set the animation to be drop
		showAnim: "drop",

		//enable the month and year drop down box
		changeMonth: true,
		changeYear: true,
		yearRange: "1800:2011",
		
		//datepicker start at current date
		gotoCurrent: true,

		//min date can only be 100 year back, eg cannot enter 1800 as the year of birth
		minDate: "-200Y",

		//max date can only be today
		maxDate: +0
		
    }); 
}
function validateFamilyMemberForm() {
	$("#addFamilyMemberForm").validate({
	        rules: {
	          name: {
				required: true
	      	  },

	      	  surname: {
	          	  required: true
	      	  }
	      	},
	});
	      
	      if(($("#addFamilyMemberForm")).valid())
	    	  alert("Record Added Sucessfully");
}

function validateLogin() {
	$("#loginForm").validate({
        rules: {
          email: {
			required: true
      	  },

      	  password: {
          	  required: true
      	  }
      	},
	});
	
	if(($("#loginForm")).valid()) {	
	    var ajax = new XMLHttpRequest();
	    ajax.open('GET', "login.php?func=login", true);
	    ajax.onreadystatechange = function() {
	        if(ajax.readyState == 4) {
	        }
	    }
	    ajax.send(null);
	}
}

function redirect() {
	windows.location="home.php";
}
